package com.ucloud.controller;

import com.ucloud.domain.Department;
import com.ucloud.service.DepartmentService;
import com.ucloud.utils.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

//@RestController
@Controller
public class DepartmentController {
@Autowired
    private DepartmentService departmentService;
//返回所有部门的信息

    //@GetMapping
    @RequestMapping(value = "/depts",method = RequestMethod.GET)
    @ResponseBody
    public Msg getDepts(){
        List<Department> list=departmentService.getDepts();
       /* System.out.println(list);
        ModelAndView modelAndView=new ModelAndView();
        modelAndView.addObject("depts",list);
        modelAndView.setViewName("success");
        return modelAndView;*/
        return Msg.success().add("depts",list);

    }

}
